home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 100 / CD-ROM 100.iso / aplic / oo1_1 / f_0020 / sbasic.jar / text / sbasic / common / 03020404.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-04-30  |  7.0 KB  |  49 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Dir Function [Runtime]</title><meta name="filename" content="text/sbasic/common/03020404"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         span.T1{
  7.                 font-weight:bold;}
  8.         </style></head><body>
  9.   
  10.   
  11.   <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="dir" xmlns:help="http://openoffice.org/2000/help">
  12.   <p class="Head1"><help:paragraphinfo state="U" number="1"/><help:key-word value="Dir; function" tag="kw66557_1"/><help:link Id="66557">Dir Function [Runtime]</help:link></p>
  13.   <p class="Paragraph"><help:paragraphinfo state="U" number="2"/>Returns the name of a file, a directory, or all of the files and the directories on a drive or in a directory that match the specified search path.</p>
  14.   <help:paragraphinfo state="E"/></help:to-be-embedded>
  15.   <p class="Head2"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>Syntax:</p>
  16.   <p class="Paragraph"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/>Dir [(Text As String) [, Attrib As Integer]]</p>
  17.   <p class="Head2"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>Return value:</p>
  18.   <p class="Paragraph"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>String</p>
  19.   <p class="Head2"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/>Parameters:</p>
  20.   <p class="Paragraph"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Text:</span> Any string expression that specifies the search path, directory or file. This argument can only be specified the first time that you call the Dir function. If you want, you can enter the path in <help:link Id="66636" Eid="urllocal" xmlns:help="http://openoffice.org/2000/help">URL notation</help:link>.</p>
  21.   <p class="Paragraph"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Attrib: </span>Any integer expression that specifies bitwise file attributes. The Dir function only returns files or directories that match the specified attributes. You can combine several attributes by adding the attribute values:</p>
  22.   <p class="Paragraph"><help:paragraphinfo state="U" number="11" xmlns:help="http://openoffice.org/2000/help"/>0 : Normal files.</p>
  23.   <p class="Paragraph"><help:paragraphinfo state="U" number="15" xmlns:help="http://openoffice.org/2000/help"/>16 : Returns the name of the directory only.</p>
  24.   <p class="Paragraph"><help:paragraphinfo state="U" number="16" xmlns:help="http://openoffice.org/2000/help"/>Use this attribute to check if a file or directory exists, or to determine all files and folders in a specific directory.</p>
  25.   <p class="Paragraph"><help:paragraphinfo state="U" number="17" xmlns:help="http://openoffice.org/2000/help"/>To check if a file exists, enter the complete path and name of the file. If the file or directory name does not exist, the Dir function returns a zero-length string ("").</p>
  26.   <p class="Paragraph"><help:paragraphinfo state="U" number="18" xmlns:help="http://openoffice.org/2000/help"/>To generate a list of all existing files in a specific directory, proceed as follows: The first time you call the Dir function, specify the complete search path for the files, for example, "D:\Files\*.sxw". If the path is correct and the search finds at least one file, the Dir function returns the name of the first file that matches the search path. To return additional file names that match the path, call Dir again, but with no arguments.</p>
  27.   <p class="Paragraph"><help:paragraphinfo state="U" number="19" xmlns:help="http://openoffice.org/2000/help"/>To return directories only, use the attribute parameter. The same applies if you want to determine the name of a volume (for example, a hard drive partition)</p>
  28.   <p class="Paragraph"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="66475" Eid="errorcode" xmlns:help="http://openoffice.org/2000/help"/></p>
  29.   <p class="Paragraph"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="66475" Eid="err5" xmlns:help="http://openoffice.org/2000/help"/></p>
  30.   <p class="Paragraph"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="66475" Eid="err53" xmlns:help="http://openoffice.org/2000/help"/></p>
  31.   <p class="Head2"><help:paragraphinfo state="U" number="20" xmlns:help="http://openoffice.org/2000/help"/>Example:</p>
  32.   <p class="PropText"><help:paragraphinfo state="U" number="21" xmlns:help="http://openoffice.org/2000/help"/>Sub ExampleDir</p>
  33.   <p class="PropText"><help:paragraphinfo state="U" number="22" xmlns:help="http://openoffice.org/2000/help"/>REM Displays all files and directories</p>
  34.   <p class="PropText"><help:paragraphinfo state="U" number="23" xmlns:help="http://openoffice.org/2000/help"/>Dim sPath As String</p>
  35.   <p class="PropText"><help:paragraphinfo state="U" number="24" xmlns:help="http://openoffice.org/2000/help"/>Dim sDir as String, sValue as String</p>
  36.   <p class="PropText"><help:paragraphinfo state="U" number="27" xmlns:help="http://openoffice.org/2000/help"/>sDir="Directories:"</p>
  37.   <p class="PropText"><help:paragraphinfo state="U" number="29" xmlns:help="http://openoffice.org/2000/help"/>sPath = CurDir</p>
  38.   <p class="PropText"><help:paragraphinfo state="U" number="30" xmlns:help="http://openoffice.org/2000/help"/>sValue = Dir$(sPath,16)</p>
  39.   <p class="PropText"><help:paragraphinfo state="U" number="31" xmlns:help="http://openoffice.org/2000/help"/>Do</p>
  40.   <p class="PropText"><help:paragraphinfo state="U" number="32" xmlns:help="http://openoffice.org/2000/help"/>If sValue <> "." and sValue <> ".." Then</p>
  41.   <p class="PropText"><help:paragraphinfo state="U" number="33" xmlns:help="http://openoffice.org/2000/help"/>if (GetAttr( sPath + getPathSeparator + sValue) AND 16) >0 then</p>
  42.   <p class="PropText"><help:paragraphinfo state="U" number="34" xmlns:help="http://openoffice.org/2000/help"/>REM get the directories</p>
  43.   <p class="PropText"><help:paragraphinfo state="U" number="35" xmlns:help="http://openoffice.org/2000/help"/>sDir = sDir & chr(13) & sValue</p>
  44.   <p class="PropText"><help:paragraphinfo state="U" number="43" xmlns:help="http://openoffice.org/2000/help"/>End If</p>
  45.   <p class="PropText"><help:paragraphinfo state="U" number="44" xmlns:help="http://openoffice.org/2000/help"/>sValue = Dir$</p>
  46.   <p class="PropText"><help:paragraphinfo state="U" number="45" xmlns:help="http://openoffice.org/2000/help"/>Loop Until sValue = ""</p>
  47.   <p class="PropText"><help:paragraphinfo state="U" number="46" xmlns:help="http://openoffice.org/2000/help"/>MsgBox sDir,0,sPath</p>
  48.   <p class="PropText"><help:paragraphinfo state="U" number="48" xmlns:help="http://openoffice.org/2000/help"/>End sub</p>
  49.  </body></html>